package C;

import java.util.Arrays;
import java.util.Scanner;

public class C10My {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        int[] F = new int[n];
        for (int i=0;i<n;i++) {
            F[i] = sc.nextInt();
        }
        sc.nextLine();
        int[][] T = new int[m][2];
        for (int i=0;i<T.length;i++) {
            int[] t = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            int sum = 0;
            for (int num:t) {
                sum+=num;
            }
            T[i][0] = sum;
            T[i][1] = i+1;
        }

        Arrays.sort(T,(a,b)->{
            return a[0]!=b[0] ?  b[0]-a[0] : a[1]-b[1];
        });

        for (int[] no : T) {
            System.out.println(no[1]);
        }
    }
}
